<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>二进制安全字符串比较</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.strchr.html">strchr</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.strcoll.html">strcoll</a></div>
 <div class="up"><a href="ref.strings.html">字符串函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.strcmp" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strcmp</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">strcmp</span> &mdash; <span class="dc-title">二进制安全字符串比较</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.strcmp-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><strong>strcmp</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str1</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$str2</code></span>
   )</div>

  <p class="simpara">
   注意该比较区分大小写。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strcmp-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">str1</code></em></dt>

     <dd>

      <p class="para">
       第一个字符串。
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">str2</code></em></dt>

     <dd>

      <p class="para">
       第二个字符串。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strcmp-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   如果 <em><code class="parameter">str1</code></em> 小于 <em><code class="parameter">str2</code></em>，返回负数；如果 <em><code class="parameter">str1</code></em> 大于 <em><code class="parameter">str2</code></em>，返回正数；二者相等则返回 0。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.strcmp-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.preg-match.html" class="function" rel="rdfs-seeAlso">preg_match()</a> - 执行一个正则表达式匹配</span></li>
    <li class="member"><span class="function"><a href="function.strcasecmp.html" class="function" rel="rdfs-seeAlso">strcasecmp()</a> - 二进制安全比较字符串（不区分大小写）</span></li>
    <li class="member"><span class="function"><a href="function.substr.html" class="function" rel="rdfs-seeAlso">substr()</a> - 返回字符串的子串</span></li>
    <li class="member"><span class="function"><a href="function.stristr.html" class="function" rel="rdfs-seeAlso">stristr()</a> - strstr 函数的忽略大小写版本</span></li>
    <li class="member"><span class="function"><a href="function.strncasecmp.html" class="function" rel="rdfs-seeAlso">strncasecmp()</a> - 二进制安全比较字符串开头的若干个字符（不区分大小写）</span></li>
    <li class="member"><span class="function"><a href="function.strncmp.html" class="function" rel="rdfs-seeAlso">strncmp()</a> - 二进制安全比较字符串开头的若干个字符</span></li>
    <li class="member"><span class="function"><a href="function.strstr.html" class="function" rel="rdfs-seeAlso">strstr()</a> - 查找字符串的首次出现</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.strchr.html">strchr</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.strcoll.html">strcoll</a></div>
 <div class="up"><a href="ref.strings.html">字符串函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
